package com.qianxx.component.activity.effects.scroll_panel;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.ViewGroup;

import com.qianxx.component.activity.effects.scroll_panel.fragment.MealFragment;

public class ViewPagerAdapter extends FragmentPagerAdapter {
    Fragment curFragment;
    public static String[] TITLES = new String[]{"点餐", "评价", "商家"};
    Fragment[] fragments = new Fragment[]{new MealFragment(), new MealFragment(), new MealFragment()};

    public ViewPagerAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public Fragment getItem(int position) {
        return fragments[position];
    }

    @Override
    public int getCount() {
        return fragments.length;
    }

    @Override
    public void setPrimaryItem(ViewGroup container, int position, Object object) {
        super.setPrimaryItem(container, position, object);
        curFragment = (Fragment) object;
    }

    public Fragment getCurFragment() {
        return curFragment;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return TITLES[position % TITLES.length];
    }
}